const Router = require('koa-router');
const router = new Router();
const {db} = require("../../models/db");


router.post('/common/doSort', async ctx => {
    try {
        let formData = ctx.request.body.formData;
        let mod = ctx.request.body.mod;
        if(mod) {
            formData.map( async row =>{
                if(row.id) {
                    await db.models[mod].update({sort: row.sort}, {
                        where: {
                            id: row.id
                        }
                    })
                }
            })
        }
        ctx.suc('')
    }
    catch (e) {
        return ctx.err(e)
    }
})






module.exports = router;